//
//  SAShareView.m
//  ShopAssistant
//
//  Created by FangGeek on 2017/11/20.
//  Copyright © 2017年 hyxt. All rights reserved.
//

#import "SAShareView.h"

@implementation SAShareView

-(void)awakeFromNib
{
    [super awakeFromNib];
    
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction)];
    [self addGestureRecognizer:tap];
    tap.delegate = self;
}

#pragma mark - 动画
- (void)showAnimation
{
    [[UIApplication sharedApplication].keyWindow addSubview:self];
    
    [UIView animateWithDuration:0.2f animations:^{
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
        self.bottomConstraint.constant = 0;
        [self layoutIfNeeded];
        
    }];
    
}

- (void)removeAnimation
{
    [UIView animateWithDuration:0.2f animations:^{
        self.bottomConstraint.constant = -200;
        [self layoutIfNeeded];
        
    } completion:^(BOOL finished) {
        [self removeFromSuperview];
    }];
    
}

#pragma mark - Action

-(void) tapAction
{
    [self removeAnimation];
}

- (IBAction)cancelAction:(id)sender {
    [self removeAnimation];
}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
    
    if (touch.view == self.mainView)
    {
        return NO;
    }
    
    return YES;
}
@end
